import { request } from '../../request';

// get list by page
export function fetchGetRoleByPage(params: Api.Common.CommonSearchParams) {
  return request<Api.System.Role.RoleInfoQueryRecord>({
    url: '/rbac/role_info/listByPage',
    method: 'post',
    data: params
  });
}

// 获取全部角色列表，提供多选框
export function fetchRoleAll() {
  return request<Api.System.Role.RoleInfoRecord[]>({
    url: '/rbac/role_info/listAll',
    method: 'get'
  });
}

// delete by id
export function fetchDeleteRoleById(id: CommonType.IdType) {
  return request({
    url: '/rbac/role_info/deleteById',
    method: 'post',
    params: {
      id
    }
  });
}

// delete batch by ids
export function fetchDeleteRoleBatchByIds(ids: CommonType.IdType[]) {
  return request({
    url: '/rbac/role_info/deleteBatchByIds',
    method: 'post',
    data: ids
  });
}

// save model
export function fetchRoleSave(model: Api.System.Role.RoleInfoFormModel) {
  return request({
    url: '/rbac/role_info/save',
    method: 'post',
    data: model
  });
}

// 获取授权，即用户角色、部门角色关联信息
export function fetchGetAuthorizeByPage(params: Api.Common.CommonSearchParams) {
  return request<Api.System.Role.RoleRelationQueryRecord>({
    url: '/rbac/role_relation/listByPage',
    method: 'post',
    data: params
  });
}

// 保存 用户/部门 角色关联信息
export function fetchSaveRoleRelation(model: Api.System.Role.RoleRelationFormModel) {
  return request({
    url: '/rbac/role_relation/save',
    method: 'post',
    data: model
  });
}

// 删除 用户/部门 角色关联信息
export function fetchDeleteRoleRelation(params: Api.System.Role.RoleRelationRecord) {
  return request({
    url: '/rbac/role_relation/deleteByParams',
    method: 'post',
    data: params
  });
}
